//
//  HelpViewCell.m
//  智慧小区
//
//  Created by 高永杨 on 2017/3/17.
//  Copyright © 2017年 zhongchuang. All rights reserved.
//

#import "HelpViewCell.h"
#import "HelpShareModel.h"
@interface HelpViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *labelTitle;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UIButton *needAuthor;
@property (weak, nonatomic) IBOutlet UIButton *helpBut;

@end

@implementation HelpViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (IBAction)helpButt:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(sendHelpViewDaiLi:)]) {
        [self.delegate sendHelpViewDaiLi:sender];
    }
}
//  citizen,
//HelpOther,
-(void)sendModel:(HelpShareModel *)modle
{
      NSString *tempStr = nil;
    self.labelTitle.text = modle.title;
    self.contentLabel.text = modle.content;
    self.timeLabel.text = modle.publishTime;
    if ([[modle helpShareType] isEqualToString:@"HelpOther"]) {
    NSString * aStr = [NSString stringWithFormat:@"有%d来帮忙",modle.personSum];
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",aStr]];
        [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:25] range:NSMakeRange(1,1)];
        
        [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor]range:NSMakeRange(1,1)];
//        [self.helpBut setTitle:@"关闭求助" forState:UIControlStateNormal];
            self.needAuthor.frame = CGRectMake(100, 200, 200, 30);
        switch (modle.helpLoveResource) {
            case 0:
                self.helpBut.userInteractionEnabled = YES;
                tempStr = @"关闭求助";
                self.needAuthor.userInteractionEnabled = YES;
                 [self.needAuthor setAttributedTitle:str forState:UIControlStateNormal];
                break;
            case 1:
                self.needAuthor.userInteractionEnabled = NO;
                [self.needAuthor setTitle:modle.userName forState:UIControlStateNormal];
                self.helpBut.userInteractionEnabled = NO;
                tempStr = @"新资源";
                break;
            default:
                break;
        }
        
        [self.helpBut setTitle:tempStr forState:UIControlStateNormal];
       
    }else
    {
      
        self.helpBut.userInteractionEnabled = NO;
        self.needAuthor.userInteractionEnabled = NO;
        [self.needAuthor setTitle: [NSString stringWithFormat:@"发布人:%@",modle.userName] forState:UIControlStateNormal];
        switch (modle.helpLoveResource) {
            case 0:
                tempStr = @"新求助";
                break;
            case 1:
                tempStr = @"新爱心";
                break;
            case 2:
                tempStr = @"新资源";
                break;
            default:
                break;
        }
        [self.helpBut setTitle:tempStr forState:UIControlStateNormal];
    }
    
}
- (IBAction)closeSeekHelp:(UIButton *)sender {
    [self.delegate closeHeplBut:sender];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
